public enum TestEnum {
    RED("red", 0),
    BLACK("black", 1),
    GREEN("green", 2),
    WHITE("white", 3);

    private String name;
    private int val;

    TestEnum(String color, int val){
        this.name = color;
        this.val = val;
    }

    public static void main(String[] args) {
        TestEnum[] testEnum2 = TestEnum.values();
        for (int i = 0; i < testEnum2.length; i++) {
            System.out.println(testEnum2[i] + " " + testEnum2[i].ordinal());
        }
        System.out.println("=========================");
        System.out.println(TestEnum.valueOf("GREEN"));
    }
}
